package com.cadre.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cadre.common.utils.DateUtil;
import com.cadre.common.utils.annotation.SysLog;
import com.cadre.common.utils.common.GenerateUUID;
import com.cadre.common.utils.oldutil.PageUtils;
import com.cadre.system.domain.officer.A04;
import com.cadre.system.mapper.A04Mapper;
import com.cadre.system.service.A04Service;
import com.cadre.system.service.DPersontagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service("A04Service")
public class A04ServiceImpl extends ServiceImpl<A04Mapper, A04> implements A04Service {
    @Autowired
    private A04Mapper A04Mapper;
    @Autowired
    private DPersontagService dPersontagService;

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    public PageUtils queryPage(Map<String, Object> params) {
//        return new PageUtils(selectPage(new Query(params).getPage(), new LambdaQueryWrapper<>()));
        return new PageUtils( new Page<>());
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    public List<A04> selectList(String personId) {
        LambdaQueryWrapper<A04> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(A04::getPersonid, personId);
        lambdaQueryWrapper.orderByAsc(A04::getSerial);
        return A04Mapper.selectList(new LambdaQueryWrapper());
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional(rollbackFor = {Exception.class})
    public int updateByPrimaryKeySelective(A04 a04) {
        return this.A04Mapper.updateByPrimaryKeySelective(a04);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional
    public int insertBatchSimple(List<A04> a04List) {
        for (A04 a04 : a04List) {
            a04.setFlowid(GenerateUUID.getUUID());
            insertSelectiveDate(a04);
        }
        return 1;
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    public List<A04> selectByxl(String personid) {
        return this.A04Mapper.selectByxl(personid);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional
    public int updateByBatch(List<A04> list) {
        return this.A04Mapper.updateByBatch(list);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional
    public int updateCodeIfnull() {
        return this.A04Mapper.updateCodeIfnull();
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional
    public int deleteByPersonId(String personid) {
        return this.A04Mapper.deleteByPersonId(personid);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    public List<A04> selectByXL(Map<String, Object> map) {
        return this.A04Mapper.selectByXL(map);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @Transactional(rollbackFor = {Exception.class})
    @SysLog(value = "新增干部学历信息", target = "A01", set = "A04", type = 0)
    public int insertSelectiveDate(A04 a04) {
        return this.A04Mapper.insert(a04);
    }

    @Override // com.tdqy.cadre.modular.profess.service.A04Service
    @SysLog(value = "删除干部学历信息", target = "A01", set = "A04", type = DateUtil.SUB_MONTH)
    public int deleteByFlowid(String[] flowid) {
        if (flowid.length < 1) {
            return 1;
        }
        return this.A04Mapper.deleteBatchIds(Arrays.asList(flowid));
    }
}
